﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 递归_汉诺塔_
{
    class Program
    {
        static void Main(string[] args)
        {
            hanoi(3, 'A', 'B', 'C');
        }
        static void Move(char from,char to)
        {
            Console.WriteLine("From{0}TO{1}", from, to);
        }
        static void hanoi(int n,char p1,char p2,char p3)
        {
            if(n==1)
            {
                Move(p1, p3); //A移动到C上
            }
            else
            {
                hanoi(n - 1, p1, p3, p2);//n-1个片子通过p3移动的p2上
                Move(p1, p3);
                hanoi(n - 1, p2, p1, p3);
            }
        }
    }
}
